package com.chen.webservice.model;

import com.chen.webservice.Utils.RuleConstants;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.chen.webservice.Utils.CityConstants;

import java.io.Serializable;
import java.util.Random;

@Data
public class Order implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("节目id")
    private Long id;

    @ApiModelProperty("节目名称")
    private String name;

    @ApiModelProperty("订单编号")
    private Long orderId;

    @ApiModelProperty("包屏节目开始时间")
    private Integer startTime;

    @ApiModelProperty("包屏节目结束时间")
    private Integer endTime;

    @ApiModelProperty("播放时长 秒")
    private Integer playTime;

    @ApiModelProperty("播放形式 包屏1，轮播0")
    private Integer playType;

    @ApiModelProperty("播放频次 次")
    private Integer playFrequency;

    @ApiModelProperty("播放周期 天")
    private Integer playPeriod;

    @ApiModelProperty("地标id")
    private Long landmarkId;

    @ApiModelProperty("商业:1、政府:2、城市之窗:3、自制:4、整点/半点广告:5")
    private Integer category;

    @ApiModelProperty("品类")
    private Integer categorySub;

    @ApiModelProperty("风格，动画、文字")
    private Integer style;

    @ApiModelProperty("色系")
    private Integer color;

    @ApiModelProperty("评分")
    private Integer rate;

    @ApiModelProperty("时效")
    private Integer aging;
    
    public Order(){
        
    }

    public Order(boolean is){
        this("new_ori_order", -1L, 15, 0, 0, 0, 0,
                RuleConstants.OrderType.ORIGIN.getValue(), RuleConstants.CateType.OTHERS.getValue(), RuleConstants.StyleType.OTHERS.getValue(),
                RuleConstants.ColorType.OTHERS.getValue(), RuleConstants.OrderRate.RATE_10.getValue(), RuleConstants.OrderAging.LONG_TERM.getValue());
    }

    public Order(String name, Long id, Integer playTime, Integer playType, Integer playFrequency, Integer startTime, Integer endTime,
                 Integer category, Integer categorySub, Integer style, Integer color, Integer rate, Integer aging){
        this.name = name;
        this.id = id;
        this.playTime = playTime;
        this.playType = playType;
        this.playFrequency = playFrequency;
        this.startTime = startTime;
        this.endTime = endTime;
        this.category = category;
        this.categorySub = categorySub;
        this.style = style;
        this.color = color;
        this.rate = rate;
        this.aging = aging;
    }
    
    public Order deepCopy(){
        return new Order(this);
    }    
    public Order(Order other){
        this.id=other.id;
        this.orderId=other.orderId;
        //    private
        this.startTime=other.startTime;
        this.endTime=other.endTime;
        this.playType=other.playType;
        this.playTime=other.playTime;
        this.playFrequency=other.playFrequency;
        this.playPeriod=other.playPeriod;
        this.landmarkId=other.landmarkId;
        this.category=other.category;
        this.categorySub=other.categorySub;
        this.style=other.style;
        this.color=other.color;
        this.rate=other.rate;
        this.aging=other.aging;
        this.name=other.name;
    }

    public Order(int startTime, int endTime) {
        this.id = System.currentTimeMillis()-randInt(1000);
        this.orderId = this.id;
        this.startTime = randInt(startTime+endTime);

        this.playTime = CityConstants.PLAY_TIME.get(randInt(5));
        this.endTime =this.startTime + this.playTime;

        this.playFrequency = 1 + randInt(3);
        this.playPeriod = 1 + randInt(30);
        this.category = RuleConstants.OrderType.getRand().getValue();
        this.categorySub = RuleConstants.CateType.getRand().getValue();
        this.style = RuleConstants.StyleType.getRand().getValue();
        this.color = RuleConstants.ColorType.getRand().getValue();
        this.rate = RuleConstants.OrderRate.getRand().getValue();
        this.aging = RuleConstants.OrderAging.getRand().getValue();
    }

    private int randInt(int bound) {
        Random random = new Random();
        return random.nextInt(bound);
    }

}
